package xyz.renyumeng.xkm.model.es;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @author renyumeng
 * @date Created in 22:27 2023/7/2
 */

@Data
@Document(indexName = "service_shop", type = "product", shards = 1, replicas = 0)
public class EsProduct implements Serializable {
    private static final long serialVersionUID = -1L;

    @Id
    private Long id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", copyTo = "descriptiveContent")
    private String productName;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", copyTo = "descriptiveContent")
    private String productDesc;

    @Field(type = FieldType.Long)
    private Long typeId;

    @Field(type = FieldType.Keyword)
    private String type;

    @Field(type = FieldType.Keyword, index = false)
    private String image;

    @Field(type = FieldType.Long)
    private Long ownerId;

    @Field(type = FieldType.Date, pattern = "yyyy-MM-dd HH:mm:ss")
    Date createTime;

    @Field(type = FieldType.Integer)
    private Integer isListed;

    @Field(type = FieldType.Integer)
    private Integer isSoled;

    /**
     * 由其他属性copy而来，主要用于搜索功能，不需要储存数据
     */
    @JsonIgnore
    @Field(type = FieldType.Text, analyzer = "ik_max_word", ignoreFields = "descriptiveContent")
    String descriptiveContent;


}
